<?php
use Migrations\AbstractMigration;

class POCOR6538 extends AbstractMigration
{
    /**
     * Change Method.
     *
     * More information on this method is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-change-method
     * @return void
	 * This class is used for adding time zone in database
	 * @author Akshay patodi <akshay.patodi@mail.valuecoders.com>
	 * @ticket POCOR-6538
     */
    public function up()
    {
		
		 // config_items
    	$this->execute('DROP TABLE IF EXISTS `zz_6538_config_items`');
        $this->execute('CREATE TABLE `zz_6538_config_items` LIKE `config_items`');
        $this->execute('INSERT INTO `zz_6538_config_items` SELECT * FROM `config_items`');
		
	    // config_item_options
	    $this->execute('DROP TABLE IF EXISTS `zz_6538_config_item_options`');
        $this->execute('CREATE TABLE `zz_6538_config_item_options` LIKE `config_item_options`');
        $this->execute('INSERT INTO `zz_6538_config_item_options` SELECT * FROM `config_item_options`');
        $this->execute('INSERT INTO `config_items` 
            (`id`, `name`, `code`, `type`, `label`, `value`, `value_selection`, `default_value`, `editable`, `visible`, `field_type`, `option_type`, `created_user_id`, `created`) VALUES 
            (6, "Time Zone", "time_zone", "System", "Time Zone", "", "", "(GMT 00:00)", 1, 1, "Dropdown", "time_zone", 1, CURRENT_DATE())');
	    
         // insert data to config_items table
        $configitemoptions = [
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-12:00) International Date Line West',
                'value' => 'Pacific/Wake',
                'order' => 1,
                'visible' => 1,
                
            ],
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-11:00) Midway Island, Samoa',
                'value' => 'US/Samoa',
                'order' => 2,
                'visible' => 1,
            ],
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-10:00) Hawaii',
                'value' => 'US/Hawaii',
                'order' => 3,
                'visible' => 1,
            ],
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-09:00) Alaska',
                'value' => 'US/Alaska',
                'order' => 4,
                'visible' => 1,
            ],
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-08:00) Pacific Time (US and Canada); Tijuana',
                'value' => 'US/Pacific',
                'order' => 5,
                'visible' => 1,
            ],
            [
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-07:00) Mountain Time (US and Canada)',
                'value' => 'US/Mountain',
                'order' => 6,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-07:00) Chihuahua, La Paz, Mazatlan',
                'value' => 'America/Chihuahua',
                'order' => 8,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-07:00) Arizona',
                'value' => 'US/Arizona',
                'order' => 9,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-06:00) Central Time (US and Canada)',
                'value' => 'US/Central',
                'order' => 10,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-06:00) Saskatchewan',
                'value' => 'Canada/Saskatchewan',
                'order' => 11,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-06:00) Guadalajara, Mexico City, Monterrey',
                'value' => 'America/Mexico_City',
                'order' => 12,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-06:00) Central America',
                'value' => 'America/Managua',
                'order' => 13,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-05:00) Eastern Time (US and Canada)',
                'value' => 'US/Eastern',
                'order' => 14,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-05:00) Indiana (East)',
                'value' => 'US/East-Indiana',
                'order' => 15,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-05:00) Bogota, Lima, Quito',
                'value' => 'America/Bogota',
                'order' => 16,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-04:00) Atlantic Time (Canada)',
                'value' => 'Canada/Atlantic',
                'order' => 17,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-04:00) Caracas, La Paz',
                'value' => 'America/La_Paz',
                'order' => 18,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-04:00) Santiago',
                'value' => 'America/Santiago',
                'order' => 19,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-03:30) Newfoundland and Labrador',
                'value' =>  'Canada/Newfoundland',
                'order' => 20,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-03:00) Brasilia',
                'value' =>  'America/Sao_Paulo',
                'order' => 21,	
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-03:00) Buenos Aires, Georgetown',
                'value' => 'America/Buenos_Aires',
                'order' => 22,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-03:00) Greenland',
                'value' => 'Greenland',
                'order' => 23,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-02:00) Mid-Atlantic',
                'value' => 'America/Noronha',
                'order' => 24,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-01:00) Azores',
                'value' => 'Atlantic/Azores',
                'order' => 25,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT-01:00) Cape Verde Islands',
                'value' => 'Atlantic/Cape_Verde',
                'order' => 26,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London',
                'value' => 'Europe/London',
                'order' => 27,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT) Casablanca, Monrovia',
                'value' => 'Africa/Monrovia',
                'order' => 28,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague',
                'value' => 'Europe/Belgrade',
                'order' => 29,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb',
                'value' => 'Europe/Warsaw',
                'order' => 30,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+01:00) Brussels, Copenhagen, Madrid, Paris',
                'value' => 'Europe/Paris',
                'order' => 31,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna',
                'value' => 'Europe/Vienna',
                'order' => 32,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+01:00) West Central Africa',
                'value' =>  'Africa/Lagos',
                'order' => 33,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Bucharest',
                'value' => 'Europe/Bucharest',
                'order' => 34,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Cairo',
                'value' => 'Africa/Cairo',
                'order' => 35,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius',
                'value' => 'Europe/Riga',
                'order' => 36,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Athens, Istanbul, Minsk',
                'value' => 'Europe/Athens',
                'order' => 37,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Jerusalem',
                'value' => 'Asia/Jerusalem',
                'order' => 38,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+02:00) Harare, Pretoria',
                'value' => 'Africa/Harare',
                'order' => 39,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+03:00) Moscow, St. Petersburg, Volgograd',
                'value' => 'Europe/Moscow',
                'order' => 40,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+03:00) Kuwait, Riyadh',
                'value' => 'Asia/Kuwait',
                'order' => 41,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+03:00) Nairobi',
                'value' => 'Africa/Nairobi',
                'order' => 42,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+03:00) Baghdad',
                'value' =>  'Asia/Baghdad',
                'order' => 43,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+03:30) Tehran',
                'value' => 'Asia/Tehran',
                'order' => 44,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+04:00) Abu Dhabi, Muscat',
                'value' => 'Asia/Muscat',
                'order' => 45,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+04:00) Baku, Tbilisi, Yerevan',
                'value' => 'Asia/Tbilisi',
                'order' => 46,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+04:30) Kabul',
                'value' => 'Asia/Kabul',
                'order' => 47,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+05:00) Ekaterinburg',
                'value' => 'Asia/Yekaterinburg',
                'order' => 48,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+05:00) Islamabad, Karachi, Tashkent',
                'value' => 'Asia/Karachi',
                'order' => 49,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi',
                'value' => 'Asia/Kolkata',
                'order' => 50,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+05:45) Kathmandu',
                'value' => 'Asia/Kathmandu',
                'order' => 51,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+06:00) Astana, Dhaka',
                'value' => 'Asia/Dhaka',
                'order' => 52,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+06:00) Sri Jayawardenepura',
                'value' => 'Asia/Colombo',
                'order' => 53,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+06:00) Almaty, Novosibirsk',
                'value' => 'Asia/Almaty',
                'order' => 54,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+06:30) Yangon Rangoon',
                'value' => 'Asia/Yangon',
                'order' => 55,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+07:00) Bangkok, Hanoi, Jakarta',
                'value' =>  'Asia/Bangkok',
                'order' => 56,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+07:00) Krasnoyarsk',
                'value' => 'Asia/Krasnoyarsk',
                'order' => 57,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+08:00) Beijing, Chongqing, Hong Kong SAR, Urumqi',
                'value' => 'Asia/Hong_Kong',
                'order' => 58,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+08:00) Kuala Lumpur, Singapore',
                'value' => 'Asia/Singapore',
                'order' => 59,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+08:00) Taipei',
                'value' => 'Asia/Taipei',
                'order' => 60,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+08:00) Perth',
                'value' => 'Australia/Perth',
                'order' => 61,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+08:00) Irkutsk, Ulaanbaatar',
                'value' => 'Asia/Irkutsk',
                'order' => 62,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+09:00) Seoul',
                'value' => 'Asia/Seoul',
                'order' => 63,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+09:00) Osaka, Sapporo, Tokyo',
                'value' =>  'Asia/Tokyo',
                'order' => 64,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+09:00) Yakutsk',
                'value' =>  'Asia/Yakutsk',
                'order' => 65,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+09:30) Darwin',
                'value' => 'Australia/Darwin',
                'order' => 66,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+09:30) Adelaide',
                'value' => 'Australia/Adelaide',
                'order' => 67,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+10:00) Canberra, Melbourne, Sydney',
                'value' => 'Australia/Sydney',
                'order' => 68,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+10:00) Brisbane',
                'value' => 'Australia/Brisbane',
                'order' => 69,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+10:00) Hobart',
                'value' => 'Australia/Hobart',
                'order' => 70,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+10:00) Vladivostok',
                'value' => 'Asia/Vladivostok',
                'order' => 71,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+10:00) Guam, Port Moresby',
                'value' => 'Pacific/Guam',
                'order' => 72,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+11:00) Magadan, Solomon Islands, New Caledonia',
                'value' => 'Asia/Magadan',
                'order' => 73,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+12:00) Fiji Islands, Kamchatka, Marshall Islands',
                'value' => 'Asia/Kamchatka',
                'order' => 74,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => '(GMT+12:00) Auckland, Wellington',
                'value' => 'Pacific/Auckland',
                'order' => 75,
                'visible' => 1,
            ],
			[
                'id' => Null,
                'option_type' => 'time_zone',
                'option' => "(GMT+13:00) Nuku'alofa",
                'value' => "Pacific/Tongatapu",
                'order' => 76,
                'visible' => 1,
            ],
			
			
        ];

        $this->insert('config_item_options', $configitemoptions);		
    }

    public function down()
    {   
	    // config_items
        $this->execute('DROP TABLE IF EXISTS `config_items`');
        $this->execute('RENAME TABLE `zz_6538_config_items` TO `config_items`');
		
	    // config_item_options
        $this->execute('DROP TABLE IF EXISTS `config_item_options`');
        $this->execute('RENAME TABLE `zz_6538_config_item_options` TO `config_item_options`');
    }
}
